package com.mazha.rabbitmq.listener;

import com.mazha.rabbitmq.pojo.domain.Book;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 使用@RabbitListener注解在类上监听
 *
 * @author leizi
 * @create 2023-12-03 22:22
 */
@Component
@RabbitListener(queues = "chat.room.queue")
@Slf4j
public class TestMqReceiver {

    /**
     * 监听消息
     *
     * @param message 消息体
     */
    @RabbitHandler
    public void process(Book message) {
        log.info("@RabbitListener注解在类上监听消息:{}", message);
    }

}
